import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class ArrayListListInterface {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();

        list.add(0, 9);
        list.add(0,8);
        list.add(0,7);

        List<Integer> collection = new ArrayList<>();
        collection.add(3);
        collection.add(2);
        collection.add(1);

        list.addAll(0, collection);

        Iterator<Integer> iterator = list.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

        Integer integer = list.get(0);
        System.out.println("integer = " + integer);

        int indexOf = list.indexOf(2);
        System.out.println("indexOf = " + indexOf);
        int lastIndexOf = list.lastIndexOf(7);
        System.out.println("lastIndexOf = " + lastIndexOf);

        list.remove(2);
        list.set(2, 10);

        for (Integer i : list) {
            System.out.println(i);
        }

        List<Integer> subList = list.subList(0, 3);
        for (Integer sub : subList) {
            System.out.println(sub);
        }

    }
}
